using FluentValidation;
using SPI.AgentServer.Models;

namespace SPI.AgentServer.Validators;

public class QueryRequestValidator : AbstractValidator<QueryRequest>
{
    public QueryRequestValidator()
    {
        RuleFor(x => x.Query)
            .NotEmpty().WithMessage("查询内容不能为空")
            .MaximumLength(1000).WithMessage("查询内容不能超过1000个字符");

        RuleFor(x => x.SessionId)
            .MaximumLength(100).WithMessage("会话ID不能超过100个字符")
            .When(x => !string.IsNullOrEmpty(x.SessionId));

        RuleFor(x => x.DatabaseName)
            .MaximumLength(50).WithMessage("数据库名称不能超过50个字符")
            .When(x => !string.IsNullOrEmpty(x.DatabaseName));
    }
}
